# from selenium import webdriver
# from selenium.webdriver.common.by import By
# from time import sleep
# import os,json
#
# class LoginGetCookie():
#
#     name = (By.ID, 'userName')
#     password = (By.ID, 'password')
#     loginbutton= (By.ID, 'but_login')
#
#
#     def loginBusiness(self):
#         driver = webdriver.Edge()
#         driver.implicitly_wait(6)
#         driver.maximize_window()
#         driver.get('http://82.157.138.248:8080/jeewms/')
#         sleep(3)
#         driver.find_element(*self.name).clear()
#         sleep(2)
#         driver.find_element(*self.name).send_keys('admin')
#         sleep(1)
#         driver.find_element(*self.password).clear()
#         sleep(2)
#         driver.find_element(*self.password).send_keys('llg123')
#         # 手动输入验证码
#         sleep(6)
#         driver.find_element(*self.loginbutton).click()
#         sleep(6)
#         print(driver.get_cookies())
#         cookies = driver.get_cookies()
#         with open(base_dir+'\data\cookie.txt', 'w') as f:
#             f.write(json.dumps(cookies))
#         sleep(2)
#         driver.quit()
#
#
#     def login_sucess(self):
#         driver = webdriver.Edge()
#         driver.implicitly_wait(6)
#         driver.maximize_window()
#         driver.get('http://82.157.138.248:8080/jeewms/')
#         sleep(3)
#         driver.delete_all_cookies()
#         with open(base_dir+'\data\cookie.txt', 'r') as f:
#             cookies = f.read()
#             cookiess = json.loads(cookies)
#             print(cookiess)
#             for cookie in cookiess:
#                 driver.add_cookie(cookie)
#                 sleep(0.5)
#         sleep(2)
#         driver.refresh()
#         sleep(12)
#         driver.quit()
#
#
# db = LoginGetCookie()
# db.login_sucess()